<?php ob_start();?>
<html>
<?php 
	$root = $_SERVER['DOCUMENT_ROOT'];
 	include($root.'/standart/head.php');
 	include($root.'/standart/dateHeader.php');
 	include($root.'/standart/checkUser.php');
?>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Geveze Cafe | Sipariş Raporu</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="../css/sb-admin.css" rel="stylesheet">
    <link href="../css/tinyBox.css" rel="stylesheet" type="text/css" media="screen"/>
    <link href="../css/jquery-ui-1.10.4.css" rel="stylesheet" type="text/css" media="screen"/>
	<link href="../css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

	<script type="text/javascript">
	
		function loadPage() {
				$.datepicker.setDefaults($.datepicker.regional['tr']); 
				$.datepicker.setDefaults({ dateFormat: 'dd/mm/yy' });
				$('.datepicker').datepicker();
				listOrders();
				parent.unloadPageX();
		}

		function listOrders(){
			url = 'getOrders.php?report=1'
				+'&begin_date='+$("#order_bgn_date").val()
				+'&end_date='+$("#order_end_date").val()
				+'&user_id='+$("#search_user_id").val();
			$('.table-responsive').html(ajx(url, ''));
			var table = $('#dataTables-example').dataTable({
	            "language": {
	                "url": "../css/plugins/dataTables/dataTablesTurkish.json"
	            },
				"footerCallback": function ( row, data, start, end, display ) {
		            var api = this.api();
		            // Remove the formatting to get integer data for summation
		            var intVal = function ( i ) {
		                return typeof i === 'string' ?
		                    i.replace(/[\$,]/g, '')*1 :
		                    typeof i === 'number' ?
		                        i : 0;
		            };
		 
		            // Total over all pages
		            var total = api
		                .column( 9 )
		                .data()
		                .reduce( function (a, b) {
		                    return intVal(a) + intVal(b);
		                } );
		 
		            // Total over this page
		            var pageTotal = api
		                .column( 9, { page: 'current'} )
		                .data()
		                .reduce( function (a, b) {
		                    return intVal(a) + intVal(b);
		                } );
		 
		            // Update footer
		            $( api.column( 9 ).footer() ).html(
		                ''+pageTotal.toFixed(2) +'TL (Genel Toplam: '+ total.toFixed(2) +' TL)'
		            );
		        }
	        } );

		$('#dataTables-example tbody').on( 'click', 'tr', function () {
	        if ( $(this).hasClass('selected') ) {
	            $(this).removeClass('selected');
	        }else {
		        if(table.$('tr.selected') != null){
	        		table.$('tr.selected').removeClass('selected');
		        }
	            $(this).addClass('selected');
	            row = $(this).find("td");
	            url = 'getOrdersItem.php?report=1'
					+'&order_id='+row[0].innerText;
				$('.table-responsive_2').html(ajx(url, ''));
				$('#dataTables-example_2').dataTable({
		            "language": {
		                "url": "../css/plugins/dataTables/dataTablesTurkish.json"
		            }
		        } );
	            }});

		}
	</script>

	
	
</head>	
	

	<body onload="loadPage()">
    <div id="wrapper">
        <div id="inner-page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Sipariş Raporu</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <!-- /.col-lg-12 -->
                <div class="col-lg-12">
                	<div class="panel panel-default">
                        <div class="panel-body">
                        	<div class="row">
                                <div class="col-lg-12">
                                	<div class="form-group" style="float: left; margin-right: 20px;">
										<label style="margin-top: 7px;">Başlangıç Tarihi</label>
									</div>
                                	<div class="form-group" style="float: left;  margin-right: 20px;">
                                        <input type="text" class="form-control datepicker" id="order_bgn_date">
									</div>
                                	<div class="form-group" style="float: left;  margin-right: 20px;">
										<label style="margin-top: 7px;">Bitiş Tarihi</label>
									</div>
                                	<div class="form-group" style="float: left;  margin-right: 20px;">
                                        <input type="text" class="form-control datepicker" id="order_end_date">
									</div>
                                	<div class="form-group" style="float: left;  margin-right: 20px;">
										<label style="margin-top: 7px;">Alıcı</label>
									</div>
                                	<div class="form-group" style="float: left;  margin-right: 20px;">
                                        <input type="text" class="form-control" id="search_user_id">
									</div>
                                	<button type="button" id="btnGetHtml" class="btn btn-default" onclick="listOrders()">Listele</button>
                                </div>
                            </div>
                        	<div class="table-responsive">
                            </div>
                            <div class="panel panel-default">
                            <div class="panel-body">
                            <div class="table-responsive_2">
                            </div>
                            </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
				<div class="col-lg-6" style="height: 450px;">
		            <iframe frameborder="0" class="frame" src="" id="container"></iframe>
				</div>
			</div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->
		
    </div>
    <!-- /#wrapper -->
    <!-- Core Scripts - Include with every page -->
    <!-- Page-Level Demo Scripts - Forms - Use for reference -->
</body>
    <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="../js/ajax.js"></script>
    <script type="text/javascript" src="../js/tinybox.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.10.4.js"></script>
    <script type="text/javascript" src="../js/plugins/dataTables/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../js/plugins/dataTables/dataTables.bootstrap.js"></script>
</html>
<?php ob_end_flush(); ?>